import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref(null)
  const token = ref('')
  const isLogin = ref(false)

  const setUserInfo = (info) => {
    userInfo.value = info
    isLogin.value = true
  }

  const clearUserInfo = () => {
    userInfo.value = null
    token.value = ''
    isLogin.value = false
  }

  return {
    userInfo,
    token,
    isLogin,
    setUserInfo,
    clearUserInfo
  }
})